<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/layui.css">
    <script src="./layui.js"></script>
    <script src="./data.js"></script>
    <title>customSelect演示</title>
    <style>
        body {
            background: #b8b8b8;
        }

        .wrap {
            width: 80%;
            margin: 40px auto;
            display: flex;
        }

        .wrap>div {
            flex: 1;
            margin: 0 10px;
        }

        .wrap p {
            font-size: 16px;
            font-weight: 600;
            line-height: 40px;
            color: #ffffff;
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div>
            <p>单选示例：</p>
            <input type="text" class="layui-input" id="radioType" />
        </div>
        <div>
            <p>多选示例：</p>
            <input type="text" class="layui-input" id="checkboxType" />
        </div>
    </div>

    <script>
        layui.config({
            base: 'lay/modules/',
        }).use(['customSelect', 'tree', 'jquery'], function () {
            const select = layui.customSelect, $ = layui.jquery, tree = layui.tree
            select.render({
                el: 'radioType',
                data: data1,
                type: 'radio',
                checked: function (obj) {
                    console.log(obj)
                    //obj.value 已选数据的title
                    //obj.data 已选数据
                }
            })
            select.render({
                el: 'checkboxType',
                data: data2,
                checkbox: true,
                checked: function (obj) {
                    // console.log(obj)
                    //obj.value 已选数据的title
                    //obj.data 已选数据
                }
            })
        })
    </script>
</body>

</html>